<!--
 * @Date: 2022-04-18 17:33:42
 * @LastEditors: xinfei
 * @LastEditTime: 2022-04-18 18:11:42
 * @FilePath: \low-code\src\components\Form\NcSubmit\NcSubmit.vue
-->
<script setup>
  import { unref, defineEmits, defineProps } from 'vue';
  const emits = defineEmits(['on-btn-click']);
  const props = defineProps({
    position: {
      type: String,
      default: 'center'
    },
    top: {
      type: [Number, String],
      default: 0
    },
    margin: {
      type: [Number, String],
      default: 0
    },
    btnList: {
      type: Array,
      default: () => {
        return [
          { label: '保存', action: 'submit', type: 'primary', size: 'mini' },
          { label: '取消', action: 'cancel', type: 'primary', size: 'mini' }
        ];
      }
    }
  });
  function onBtnClick(item) {
    emits('on-btn-click', unref(item));
  }
</script>
<template>
  <div :style="{ 'margin-top': props.top + 'px', 'text-align': props.position }">
    <NstdButton
      v-for="(item, index) in props.btnList"
      :key="index"
      :type="item.type"
      :size="item.size"
      @click="onBtnClick(item)"
      :style="{ 'margin-left': props.margin + 'px', 'margin-right': props.margin + 'px' }"
    >
      {{ item.label }}</NstdButton
    >
  </div>
</template>
